package com.dmlll.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dmlll.VO.HospitalPurchaseInputVO;
import com.dmlll.VO.PurchaseDrugDetailVO;
import com.dmlll.domain.DrugMessage;
import com.dmlll.domain.HospitalPurchaseInput;
import com.dmlll.domain.Purchase;
import com.dmlll.domain.PurchaseDrupDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 * 采购单药品明细 Mapper 接口
 * </p>
 *
 * @author dmLll
 * @since 2021-03-31
 */
public interface PurchaseDrupDetailMapper extends BaseMapper<PurchaseDrupDetail> {
    @Results(
            id = "purchaseDrugDetail",
            value = {
                    @Result(column = "id",property = "id",id = true),
                    @Result(column = "purchase_id",property = "purchaseId"),
                    @Result(column = "drug_message_id",property = "drugMessageId"),
                    @Result(column = "provider_id",property = "providerId"),
                    @Result(column = "win_price",property = "winPrice"),
                    @Result(column = "trading",property = "trading"),
                    @Result(column = "purchase_amount",property = "purchaseAmount"),
                    @Result(column = "purchase_price",property = "purchasePrice"),
                    @Result(column = "purchase_state",property = "purchaseState"),
                    @Result(column = "drug_message_id",property = "drugMessage",
                            one = @One(select = "com.dmlll.mapper.DrugMessageMapper.selectById")),
                    @Result(column = "provider_id",property = "provider",
                            one = @One(select = "com.dmlll.mapper.ProviderMapper.selectById"))

            }
    )
    @Select("select * from purchase_drup_detail where purchase_id = #{purchaseId}")
    List<PurchaseDrupDetail> getDetailAndDrug(Integer purchaseId);

    IPage<PurchaseDrupDetail> getAvaPurchaseDrupDetail(IPage<PurchaseDrupDetail>iPage, @Param("purchaseDrupDetail") PurchaseDrupDetail purchaseDrupDetail, @Param("purchase") Purchase purchase, @Param("drugMessage") DrugMessage drugMessage, @Param("providerId") Integer providerId, @Param("input") HospitalPurchaseInputVO input);
}
